package com.excel.data.convert;

import java.math.BigDecimal;
import java.time.LocalTime;
import org.apache.poi.ss.usermodel.DateUtil;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public class EasyExcelLocalTimeConverter implements Converter<LocalTime> {
    @Override
    public Class<?> supportJavaTypeKey() {
        return LocalTime.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
       return CellDataTypeEnum.NUMBER;
    }

    @Override
    public LocalTime convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
    	
    	BigDecimal bigDecimal = cellData.getNumberValue();
    	
    	double value = bigDecimal.doubleValue();
//    	
//    	DateUtil.getLocalDateTime(value, false, true).toLocalTime()
//    	
//    	Date d = Date.from(.);
//    	
//    	 Format df = new ExcelGeneralNumberFormat(Locale.CHINESE, false);
//    	
//    	 String  res = df.format(d);
//    	 
    	
    	return DateUtil.getLocalDateTime(value, false, true).toLocalTime();
    }

}
